<template>
  <div style="background:#f2f2f2;width:100%;height:100%;">
    <!-- <button  @click="scroll"> 121212</button> -->
    <van-nav-bar 
    v-if="configPermission"
    title="盘点任务" 
    left-arrow 
    @click-left="onClickLeft" 
    right-text="我创建的>"
    @click-right="onClickRight"
    />

    <van-nav-bar 
    v-else
    title="盘点任务" 
    left-arrow 
    @click-left="onClickLeft" 
    />
    <div class="itembot">
      <div style="color:blue">未完成</div>
      <div style="color:black">
        <router-link :to="{name:'testover'}" style="color:#ccc">
          已完成
        </router-link>
      </div>
    </div>
    <div class="list">
      <div class="list-item" v-for="(item,index) in option1" :key="index">
        <div class="itemtop">
          <div class="topright">
            <div class="top">
              <div>{{item.NAME }}
              </div>
            </div>
            <div style="height:30px ;margin-top:10px ;">
              <div>已完成</div>
              <div>未完成</div>
            </div>
            <div style="height:19px;">
              <div>{{ item.DONE }}
              </div>
              <div>
                {{ item.TODO }}</div>
            </div>
          </div>
        </div>
        <div class="bottom">
          <div class="createtime">
            创建时间:{{ getExactTime(item.CREATEDATE) }}
          </div>
          <!-- <div>完成时间:2023-01-22</div> -->
        </div>
        <div class="pandian" @click="handleGopan(item)">
          开始盘点
        </div>
      </div>
    </div>
  </div>
</template>
  
  <script>
import awsuiAxios from '../awsuiAxios';

export default {
  data() {
    return {
      option1: '',
      configPermission:configPermission
      // aaa:e.target.scrollTop
    }
  },
  methods: {
    scroll(){ //document.querySelector(".list")
document.querySelector(".list").scrollTop=168
      // console.log(3333333322,document.querySelector(".list").scrollTop);
    },
    handleGopan(item){
      console.log(333333333333333333,item.BINDID);
      this.$store.state.CurrentAssets = item
      this.$router.push({path:'/inventory',query:{data:1}})
    },
    onClickLeft() { 
      this.$router.back()
    },
    onClickRight(){
      this.$router.push('/carry')
    },
    addForm() {
      // alert('你好啊')
    },
    getExactTime(time) {
        var date = new Date(time);
        // var date = new Date(time* 1000);
        var year = date.getFullYear() + '-';
        var month = (date.getMonth()+1 < 10 ? '0' + (date.getMonth()+1) : date.getMonth()+1) + '-';
        var dates = date.getDate() + ' ';
        
        return year + month + dates ;
 }
  },
  mounted() {
    // console.log(3333333322,document.documentElement.scrollTop);
    this.$store.state.isEND = 0
    this.$store.state.active = 0
    const that = this;
    awsuiAxios.post({
      url: 'jd',
      data: {
        // cmd: "com.awspaas.user.apps.assetinventory_selectCompany",
        cmd: "com.awspaas.user.apps.assetinventory_selectAssetTask",
        sid: sid,
        flag: 0
      }
    }).then(function (ro) {
      if (ro.result == 'ok') {
        // that.message = ro.data.staffList
        // that.$router.push({path:'/show',query:{data:ro.data.staffList}})
        console.log(ro);
        that.option1 = ro.data.assetTask

      } else {
        // Toast.fail('扫码失败：' + ro.msg);
      }
    }).catch(error => {
      console.log(error);
    })
  }
}
  </script>
  <style scoped>
.topmes {
  width: 100%;
  height: 150px;
  background: #cccccc;
  padding-top: 10px;
  position: relative;
}
.itembot {
  display: flex;
  background: white;
}
.itembot div {
  width: 50%;
  text-align: center;
  height: 40px;
  line-height: 40px;
  color: #cccccc;
  padding: 2px 0;
  font-weight: bold;
}
.list {
  margin-top: 9px;
  width: 100%;
  height: 70%;
  background: #f2f2f2;
  overflow-y: scroll;
}
.list-item {
  width: 100%;
  margin-top: 10px;
  height: 160px;
  background: white;
}
.itemtop {
  display: flex;
  border-bottom: 1px solid #ccc;
}
.top {
  display: flex;
  width: 100%;
  height: 30px;
  align-content: center;
  border-bottom: 1px solid #ccc;
}
.topright {
  justify-content: space-around;
  padding: 4px 0 4px 0;
  width: 100%;
}

.topright div {
  display: flex;
  justify-content: space-around;
  font-size: 13px;
}
.bottom {
  display: flex;
  justify-content: space-around;
}
.button {
  position: relative;
  width: 250px;
  height: 30px;
  text-align: center;
  line-height: 30px;
  margin-top: 20px;
  margin-left: 60px;
  background-color: skyblue;
}
.pandian{
  border-top: 1px solid #ccc;
  text-align: center;
  line-height: 40px;
  color:blue;
}
.createtime{
  height: 30px;
  line-height: 30px;
}
</style>